const isMobile = navigator.userAgent.match(
  /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i,
);
export const orientationScroll = (el: any, width: number, height: number) => {
  // 判断当前屏幕是否横屏
  if (window.orientation == null || window.orientation === 180 || window.orientation === 0) {
    // 竖屏状态则旋转容器，并让高等于宽，宽等于高
    // && width < height
    el.style.webkitTransform = el.style.transform = `rotate(90deg)`;
    el.style.width = `${height}px`;
    el.style.height = `${width}px`;
    el.style.minHeight = `${width}px`;
    el.style.transformOrigin = `${width / 2}px center`;
    el.style.webkitTransformOrigin = `${width / 2}px center`;
    const designHeight = 900; // 设计稿高度，根据你的设计稿来设置
    const realHeight = document.documentElement.clientWidth || document.body.clientWidth; // 当前视口的高度
    const rem = (realHeight / designHeight) * 144; // 根据设计稿高度和当前视口高度计算rem值
    setTimeout(() => {
      document.documentElement.style.fontSize = `${rem}px`; // 设置根元素的字体大小
    }, 100);
    // alert(rem)
  } else if (window.orientation === 90 || window.orientation === -90) {
    el.style.webkitTransform = el.style.transform = `rotate(0)`;
    el.style.width = `${width}px`;
    el.style.height = `${height}px`;
    el.style.minHeight = `${height}px`;
    el.style.transformOrigin = `0px 0px`;
    el.style.webkitTransformOrigin = `0px 0px`;
    const designHeight = 900; // 设计稿高度，根据你的设计稿来设置
    const realHeight = document.documentElement.clientHeight || document.body.clientHeight; // 当前视口的高度
    const rem = (realHeight / designHeight) * 144; // 根据设计稿高度和当前视口高度计算rem值
    setTimeout(() => {
      document.documentElement.style.fontSize = `${rem}px`; // 设置根元素的字体大小
    }, 100);
  }
};
// if (isMobile) {
//   let dom = document.getElementById('body');
//   console.log(dom)
//   orientationScroll(freePreview.value, document.documentElement.clientWidth, document.documentElement.clientHeight);
// }
